package com.xj.opcua.client.util;

import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId;
import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
import org.eclipse.milo.opcua.stack.core.Identifiers;

public enum DataValueTypeEnum {
	
	Boolean(Identifiers.Boolean,"boolean"),
    SByte(Identifiers.SByte,"byte"),
    Byte(Identifiers.Byte,"byte"),
    Int16(Identifiers.Int16,"short"),
    UInt16(Identifiers.UInt16,"short"),
    Int32(Identifiers.Int32,"int"),
    UInt32(Identifiers.UInt32,"int"),
    Int64(Identifiers.Int64,"long"),
    UInt64(Identifiers.UInt64,"long"),
    Float(Identifiers.Float,"Float"),
    Double(Identifiers.Double,"Double"),
    String(Identifiers.String,"String"),
    
    Organizes(Identifiers.Organizes,"Organizes"),
    ;

	public NodeId nodeId;
	public String javaType;
	
	DataValueTypeEnum(NodeId nodeId, String javaType) {
        this.nodeId = nodeId;
        this.javaType = javaType;
    }
	
	public static DataValueTypeEnum getByCode(ExpandedNodeId expandedNodeId){
        for (DataValueTypeEnum value : values()) {
            if (value.nodeId.equals(expandedNodeId)) {
                return value;
            }
        }
        return DataValueTypeEnum.String;
    }
}
